/**
 * Created by AllanXu on 01/03/2016.
 */
define(function (require) {
	var Vue = require('vue'),
		Config = require('config'),
		_ = require('ajax'),
		utilities = require('utilities'),
		id = sessionStorage.id;

	var app = new Vue({
		el: '#uc_update_pass',
		data: {
			password: '',
			rePassword: ''
		},
		methods: {
			init: function () {
			},
			save: function () {
				if (app.password.trim() === '' || app.rePassword.trim() === '') {
					alert('不能为空！');
				} else if (app.password.trim() !== app.rePassword.trim()) {
					alert('两次输入密码不一致！');
				} else {
					_(Config.SERVICE.USERCENTER.PASSWORD_UPDATE, {
						'id': id,
						'xgmember.passWord': app.password
					}, function (data) {
						if (data.code == 200 && data.type === 'SUCCESS') {
							alert('修改成功！');
							history.back();
						} else {
							alert(data.errmsg);
						}
					});
				}
			}
		}
	});
	app.init();
});
